package Visitor;

import Entities.*;
import Entities.Advantages.*;

public class BarCollisionVisitor implements IVisitor {

    private Bar bar;

    public BarCollisionVisitor(Bar bar) {
        this.bar = bar;
    }

    @Override
    public Drawable visit(Bar bar) {
        return null;
    }

    @Override
    public Drawable visit(Ball ball) {
        return null;
    }

    @Override
    public Drawable visit(Boundary boundary) {
        return null;
    }

    @Override
    public Drawable visit(IAdvantage advantage) {
        if (bar.getX() <= advantage.getX() + advantage.getWidth() / 2 && advantage.getX() + advantage.getWidth() / 2 <= bar.getX() + bar.getWidth()){
            if (bar.getY() <= advantage.getY() + advantage.getHeight() && advantage.getY() + advantage.getHeight() <= bar.getY() + bar.getHeight()){
                return advantage;
            }
        }
        return null;
    }

    @Override
    public Drawable visit(Brick brick) {
        return null;
    }

    @Override
    public Drawable visit(Drawable drawable) {                                                      
        return null;
    }

    @Override
    public Drawable visit(Hinder hinder) {
        return null;
    }

    @Override
    public Drawable visit(DecreaseBarSize decreaseBarSize) {
        return visit((IAdvantage) decreaseBarSize);
    }

    @Override
    public Drawable visit(IncreaseBarSize increaseBarSize) {
        return visit((IAdvantage) increaseBarSize);
    }

    @Override
    public Drawable visit(DecreaseBallSpeed decreaseBallSpeed) {
        return visit((IAdvantage) decreaseBallSpeed);
    }

    @Override
    public Drawable visit(IncreaseBallSpeed increaseBallSpeed) {
        return visit((IAdvantage) increaseBallSpeed);
    }

    @Override
    public Drawable visit(MissileAdvantage missileAdvantage) {
        return null;
    }

    @Override
    public Drawable visit(ThreeBallsAdvantage threeBallsAdvantage) {
        return visit ((IAdvantage)threeBallsAdvantage) ;
    }
}
